package edu.hubu.commons.handler;

import com.alibaba.csp.sentinel.slots.block.BlockException;
import edu.hubu.commons.model.CommonResult;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author Retain
 * @date 2021/2/10 15:57
 * 自定义的服务降级限流handler，需在全局handler配置忽略
 */
public class CustomBlockHandler {
    public static CommonResult handleQueryException(String id,BlockException e){
        // 429 Too Many Requests (太多请求)
        return new CommonResult().setCode(429).setMessage("系统繁忙。请稍后再试");
    }
    public static CommonResult handleQueryPagedException(Integer currentPage,Integer pageSize,String orderBy,BlockException e){
        return new CommonResult().setCode(429).setMessage("系统繁忙。请稍后再试");
    }
}
